package cn.pkubangbang.demo.democontact.entity;

import java.time.Instant;
import java.util.List;
import java.util.Set;

/**
 * @Author: zhangzhenbang@k2data.com.cn
 * @Date: 2018-08-24 15:34
 */
public class CommonMessage {

    /**
     * 当前用户
     */
    private Person self;
    /**
     * 用户的角色
     */
    private Set<Role> roles;
    /**
     * 当前服务器时间戳
     */
    private Instant serverTime;
    /**
     * 登录以来，用户上一次操作的时间戳
     */
    private Instant lastActive;
    /**
     * 最近一段时间内用户发送的请求数。当这个数大于某个值时会触发403（用于防止DDos）
     */
    private Integer hitCount;
    /**
     * 操作码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;
    /**
     * 当前目录的“功能菜单”，用户可以通过这个菜单继续下一步操作
     */
    private List<MenuOption> menu;


    public CommonMessage() {
    }

    public CommonMessage(Person self, Set<Role> roles, Instant serverTime, Instant lastActive,
        Integer hitCount, Integer code, String message) {
        this.self = self;
        this.roles = roles;
        this.serverTime = serverTime;
        this.lastActive = lastActive;
        this.hitCount = hitCount;
        this.code = code;
        this.message = message;
    }

    public Person getSelf() {
        return self;
    }

    public void setSelf(Person self) {
        this.self = self;
    }

    public Set<Role> getRoles() {
        return roles;
    }

    public void setRoles(Set<Role> roles) {
        this.roles = roles;
    }

    public Instant getServerTime() {
        return serverTime;
    }

    public void setServerTime(Instant serverTime) {
        this.serverTime = serverTime;
    }

    public Instant getLastActive() {
        return lastActive;
    }

    public void setLastActive(Instant lastActive) {
        this.lastActive = lastActive;
    }

    public Integer getHitCount() {
        return hitCount;
    }

    public void setHitCount(Integer hitCount) {
        this.hitCount = hitCount;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<MenuOption> getMenu() {
        return menu;
    }

    public void setMenu(List<MenuOption> menu) {
        this.menu = menu;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("CommonMessage{");
        sb.append("self=").append(self);
        sb.append(", roles=").append(roles);
        sb.append(", serverTime=").append(serverTime);
        sb.append(", lastActive=").append(lastActive);
        sb.append(", hitCount=").append(hitCount);
        sb.append(", code=").append(code);
        sb.append(", message='").append(message).append('\'');
        sb.append(", menu=").append(menu);
        sb.append('}');
        return sb.toString();
    }
}
